package com.nuoniu.sibanyun.controller.finance;


import com.nuoniu.sibanyun.common.BaseController;
import com.nuoniu.sibanyun.common.lang.StringUtils;
import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.entity.finance.ErpAbstract;
import com.nuoniu.sibanyun.service.finance.IErpAbstractService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 凭证摘要 前端控制器
 * </p>
 *
 * @author 小啊刚
 * @since 2022-04-24
 */
@RestController
@RequestMapping("/erp/abstract")
@Api(tags = "凭证摘要管理")
public class ErpAbstractController extends BaseController {

    @Autowired
    private IErpAbstractService abstractService;

    @ApiOperation("获取列表")
    @GetMapping("getList")
    public HttpResult getList() {
        return HttpResult.ok(abstractService.getList());
    }

    @ApiOperation("保存")
    @PostMapping("save")
    public HttpResult save(@RequestBody ErpAbstract erpAbstract) {
        if(StringUtils.isBlank(erpAbstract.getContent())) {
            return HttpResult.error("摘要不能为空");
        }

        abstractService.saveAbstract(erpAbstract);
        return HttpResult.ok();
    }

    @ApiOperation("删除")
    @DeleteMapping("deleteById")
    public HttpResult deleteById(Long id) {
        return HttpResult.ok(abstractService.removeById(id));
    }
}
